home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DJGPP
/
DJTST111.ZIP
/
tests
/
t14.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-05
|
533b
|
31 lines
#include <stdio.h>
#include <fcntl.h>
main()
{
FILE *f;
int fd;
char buf[10];
f = fopen("t14.dat", "w");
fwrite("abcdefghijklmnopqrstuvxyz\n", 26, 1, f);
fclose(f);
fd = open("t14.dat", O_WRONLY|O_BINARY);
if (fd < 0)
return -1;
ftruncate(fd, 20);
close(fd);
f = fopen("t14.dat", "r");
fread(buf, 5, 1, f);
buf[5] = 0;
printf("first pass: %s\n", buf);
rewind(f);
fread(buf, 5, 1, f);
buf[5] = 0;
printf("second pass: %s\n", buf);
fclose(f);
return 0;
}